﻿<c:BaseControl x:Class="personalplaner.gui.stamm.views.AnstellungsStamm"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:bs="clr-namespace:personalplaner.business.stamm;assembly=personalplaner.business"
        xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
        xmlns:fac="clr-namespace:personalplaner.gui.stamm.viewmodels.factories"
        vm:ViewModelLoader.FactoryType="{x:Type fac:AnstellungStammModelFactory}"
        xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
               xmlns:p="clr-namespace:personalplaner.gui.Properties" Name="baseControl"
             Foreground="#E1000000">

    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--<ResourceDictionary Source="/personalplaner.common;component/resources/TabControlStyles.xaml"/>-->
                <ResourceDictionary Source="/personalplaner.common;component/resources/styles/WhiteStyleTemplates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>
    
    <Grid >

        <Grid.Resources>
            <DataTemplate DataType="{x:Type bs:Anstellung}">
                <Grid Margin="0,0,20,0">
                    <Grid.ColumnDefinitions>
                        <!--<ColumnDefinition Width="30"/>-->
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <!--<TextBlock Text="{Binding AnstellungID}" Grid.Column="0" Margin="5,0,5,0"/>-->
                    <TextBlock Text="{Binding Name}" Grid.Column="1"/>
                </Grid>
            </DataTemplate>
        </Grid.Resources>
    
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <ListBox ItemsSource="{Binding Anstellungen}" SelectedItem="{Binding ActiveGridItem}" Margin="10,10,0,0"/>
        
        <!--<DataGrid ItemsSource="{Binding Anstellungen}"
                      SelectedItem="{Binding ActiveGridItem}"
                      CanUserAddRows="False"
                      AutoGenerateColumns="False"
                      CanUserSortColumns="False"
                      VerticalScrollBarVisibility="Auto"
                      Margin="5,5,0,0"
                  Background="White"
                  BorderBrush="Black"
                      >
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" IsReadOnly="True" Binding="{Binding AnstellungID}" MinWidth="40"/>
                <DataGridTextColumn Header="Name" IsReadOnly="True" Binding="{Binding Name}" MinWidth="100"/>
            </DataGrid.Columns>
        </DataGrid>-->

        <!--<Border BorderBrush="Black" BorderThickness="1" Background="White" Margin="5,5,5,0" Padding="5" Grid.Column="1">-->

        <GridSplitter Width="4" Background="Transparent"/>
        
        <GroupBox Margin="5,5,5,0" Grid.Column="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="70"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="130"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock VerticalAlignment="Center" Text="Name"/>
                <TextBox Grid.Column="1" Margin="2"
                         IsEnabled="{Binding DataContext.IsEditEnabled, ElementName=baseControl}"
                         DataContext="{Binding SelectedAnstellung}" 
                         Text="{FocusBinding Path=Name, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"/>

                <TextBlock VerticalAlignment="Top" Grid.Row="1" Text="Beschreibung" />
                <TextBox Grid.Column="1" Grid.Row="1" AcceptsReturn="True" TextWrapping="Wrap" Margin="2" 
                         IsEnabled="{Binding DataContext.IsEditEnabled, ElementName=baseControl}"
                         DataContext="{Binding SelectedAnstellung}" 
                         Text="{FocusBinding Path=Beschreibung, ValidatesOnDataErrors=True}"/>

                <TextBlock Grid.Row="2" Text="Priorität"/>
                <c:NumericTextBox Grid.Row="2" Grid.Column="1" Margin="2"
                                  IsEnabled="{Binding DataContext.IsEditEnabled, ElementName=baseControl}"
                                  DataContext="{Binding SelectedAnstellung, ValidatesOnDataErrors=True}" 
                                  Text="{Binding Prioritaet}"/>

                <TextBlock Grid.Row="3" Text="Einsätze pro Tag"/>
                <c:NumericTextBox Grid.Row="3" Grid.Column="1" Margin="2"
                                  IsEnabled="{Binding DataContext.IsEditEnabled, ElementName=baseControl}"
                                  DataContext="{Binding SelectedAnstellung, ValidatesOnDataErrors=True}" 
                                  Text="{Binding EinsatzProTag}"/>

                <TextBlock Grid.Row="4" Text="Im Saldo mitrechnen"/>
                <CheckBox Grid.Row="4" Grid.Column="1" Margin="2,3,2,3"
                          IsEnabled="{Binding DataContext.IsEditEnabled, ElementName=baseControl}"
                          DataContext="{Binding SelectedAnstellung, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" 
                          IsChecked="{Binding IsGerechnet}"/>

                <TextBlock Grid.Row="5" Text="Ausgebildet"/>
                <StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="1">
                    <CheckBox Margin="2,3,2,3" IsEnabled="{Binding DataContext.IsEditEnabled, ElementName=baseControl}"
                              DataContext="{Binding SelectedAnstellung, ValidatesOnDataErrors=True}"
                              IsChecked="{Binding IsAusgelernt}"/>
                </StackPanel>

                <TextBlock Text="{x:Static p:Resources.AnstellungBeschreibung}" Grid.Row="6" Grid.Column="1" TextWrapping="Wrap" Margin="0,10,0,0"/>

            </Grid>
        </GroupBox>

        <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,20,40,20">
            <Button MinWidth="60" Margin="5" 
                    Command="{Binding DeleteCommand}">
                <TextBlock Text="Löschen"/>
            </Button>
            <Button MinWidth="60" Margin="5" 
                    Command="{Binding NewCommand}">
                <TextBlock Text="Neu"/>
            </Button>
            <Button MinWidth="60" Margin="5"
                    Command="{Binding SaveCommand}">
                <TextBlock Text="Speichern"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsDefault="True" 
                    Command="{Binding OkCommand}">
                <TextBlock Text="OK"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsCancel="True" 
                    Command="{Binding CancelCommand}">
                <TextBlock Text="Abbrechen"/>
            </Button>
        </StackPanel>

    </Grid>
</c:BaseControl>
